<?php 
/* This function works out all the attacks, returns 0 when done  */

include("scanIntoArrayFunctions.php"); 
// defines functions ScanAttacks and ScanDefence
include("Checks.php");
/* defines CheckAttacksRemaining, CheckNextAttack, CheckReturnAttack, 
 *         CheckOtherAtker,
 */
include("ResolveClash.php");
// defines twoMidfield, oneVsBase, midfieldchaos,
   //include("resolveAttacks2.php");
   // works with base attacks

$Attacks = ScanAttacks( /* TODO REQUIRES SOMETHING*/  );
$Defence = ScanDefence( /* TODO REQUIRES SOMETHING*/  );
$DmgTable;
  // $AttacksOnBase = array ()      TODO

// Loop executes all midfield battles
while( CheckAttacksRemaining( $Attacks ) == 3 )  /*TODO do i need ref */
{
  $attacker = CheckNextAttack( $Attacks );  //returns ID
  $target = $Attacks[ $attacker ][5];
  if( CheckReturnAttack( $target ) != -1 )  //returns ID
  {
    twoMidfield( $Attacks, $attacker, CheckReturnAttack( $target ) ); 
    continue;  /* HELP need pass-by-reference... */
  }
  if( 1 == CheckOtherAtker( $Attacks, $attacker, $target ) )
      midfieldchaos( $Attacks, $attacker, $target );
}

// This executes all base battles
while( CheckAttacksRemaining == 2 )  //only base attacks left
{
  // resolveAttacks2( $AttacksOnBase, $Defence )
}


return 0;
?>